package com.guochao.service.impl;

import com.guochao.dao.ShoCartMapper;
import com.guochao.dao.ShoppingCartMapper;
import com.guochao.entity.ShoppingCart;
import com.guochao.service.ShoCartService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ShoCartServiceIMPL implements ShoCartService {

    @Resource
    private ShoppingCartMapper shoppingCartMapper;

    @Override
    public int addCart(ShoppingCart cart) {
        return shoppingCartMapper.addCart(cart);
    }

    @Override
    public List<ShoppingCart> selAllCart(Integer uid) {
        return shoppingCartMapper.selAllCart(uid);
    }

    //查找购物车是否有该物品
    @Override
    public ShoppingCart FindCartByID(Integer uid,Integer pid,String size) {
        System.out.println("uid="+uid+"pid="+pid+"size"+size);
        System.out.println("ASD:"+shoppingCartMapper.FindCartById(uid,pid,size));
        return shoppingCartMapper.FindCartById(uid,pid,size);

    }


    @Override
    //增加已有购物车中商品的数量
    public int updateCart(ShoppingCart cart) {
        return shoppingCartMapper.updateByPrimaryKey(cart);
    }

    @Override
    public int delCartByID(Integer cartid) {
        return shoppingCartMapper.delCartByID(cartid);
    }

    @Override
    //批量删除购物车
    public int delCartByIds(Integer[] cartids){
        System.out.println(cartids.length);
        return shoppingCartMapper.delCartByIds(cartids);}
}
